package com.bristua.barcode.customer.biz;

import com.bristua.barcode.common.util.HttpSessionUtil;
import com.bristua.barcode.customer.dao.TCustomerMapper;
import com.bristua.barcode.customer.model.TCustomer;
import com.bristua.barcode.customer.model.condition.TCustomerExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2019/8/25.
 */
@Service
public class GetCustomerIdBiz {

    @Resource
    private TCustomerMapper tCustomerMapper;

    @Autowired
    private HttpSessionUtil httpSessionUtil;

    public String getCustomerId() {
        String userId = httpSessionUtil.getUserId();
        TCustomerExample tCustomerExample = new TCustomerExample();
        tCustomerExample.createCriteria().andCustomerNoEqualTo(userId);
        List<TCustomer> tCustomers = tCustomerMapper.selectByExample(tCustomerExample);
        if (tCustomers != null && tCustomers.size() > 0) {
            return tCustomers.get(0).getCustomerId();
        }
        return null;
    }
}
